package com.jt.controller;

import com.jt.mapper.UserMapper;
import com.jt.pojo.UserPojo;
import com.jt.service.UserService;
import com.sun.org.apache.xpath.internal.operations.Or;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/vue")
@CrossOrigin
public class UserController {
    @Autowired
    private UserService userService;
    @GetMapping("/findAll")
    public List<UserPojo> findAll(){
        return userService.findAll();
    }
    @PostMapping("/saveUser")
    public String saveUser(@RequestBody UserPojo userPojo){
        userService.saveUser(userPojo);
        return "新增成功！！！";
    }
    @DeleteMapping("/deletUser/{id}")
    public String deletUser(@PathVariable Integer id){
        userService.deletUser(id);
        return "删除成功";
    }
    @PutMapping("/updateUser")
    public String updateUser(@RequestBody UserPojo userPojo){
        userService.updateUser(userPojo);
        return "修改成功!!";
    }
}
